#include "widget.h"
#include "ui_widget.h"
#include <QShortcut>
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    QShortcut* shortcut1 = new QShortcut(this);
    QShortcut* shortcut2 = new QShortcut(this);

    shortcut1->setKey(QKeySequence('-'));
    shortcut2->setKey(QKeySequence('+'));

    connect(shortcut1,&QShortcut::activated,this,&Widget::subValue);
    connect(shortcut2,&QShortcut::activated,this,&Widget::addValue);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::addValue()
{
    int value = ui->horizontalSlider->value();
    ui->horizontalSlider->setValue(value+10);
}

void Widget::subValue()
{
    int value = ui->horizontalSlider->value();
    ui->horizontalSlider->setValue(value-10);
}


void Widget::on_horizontalSlider_valueChanged(int value)
{
    ui->label->setText("当前的值为："+QString::number(value));
}
